% TEST_ID: LANG-EXPAND-0078
% CATEGORY: stdlib/arithmetic_ops/bitops
% 测试 bitcmp 函数
function test_bit_bitcmp()
A = int8(-11);
cmp = bitcmp(A);
result = 10;
assert(isa(cmp, 'int8'));
assert_istrue(cmp, result);

A = int16(-118);
cmp = bitcmp(A);
result = 117;
assert(isa(cmp, 'int16'));
assert_istrue(cmp, result);

A = uint8(126);
cmp = bitcmp(A);
result = 129;
assert(isa(cmp, 'uint8'));
assert_istrue(cmp, result);

A = int64([126 234 235; 243 23 324]);
cmp = bitcmp(A);
result = [-127   -235   -236
   -244    -24   -325];
assert(isa(cmp, 'int64'));
assert_istrue(cmp, result);


cmp = bitcmp(64,'uint8');
maxint = intmax('uint8') - 64;
assert(isa(cmp, 'double'));
assert_istrue(cmp, maxint);

cmp = bitcmp([64 123; 3 23],'uint8');
result = [191   132
   252   232];
assert(isa(cmp, 'double'));
assert_istrue(cmp, result);

end
function assert_istrue(x, y)
    assert(isequal(x, y));
end